<?php class indexControl extends control{	function index(){		if(isset($_SESSION['user'])){			unset($_SESSION['user']);		}		$this->display();	}	function code(){		$code=new code(80,30);		$code->show();	}	function login(){		$db=new mysql("user");		$rows=$db->select();		$arr=array();		if(strtoupper($_SESSION['code'])!=strtoupper($_POST['code'])){			$arr['state']=1;			$arr['msg']="验证码错误！";			echo json_encode($arr);			exit;		}		$u=false;		$p=false;		foreach($rows as $v){			if($v['uname']==$_POST['user']){				$u=true;				if($v['pwd']==md5($_POST['pwd'])){					$p=true;				}			}		}		if(!$u){			$arr['state']=2;			$arr['msg']="用户名不存在！";			echo json_encode($arr);			exit;		}		if(!$p){			$arr['state']=3;			$arr['msg']="密码错误！";			echo json_encode($arr);			exit;		}		$arr['state']=4;		$_SESSION['user']=$_POST['user'];		echo json_encode($arr);	}}?>